// 统一当前项目的所有接口请求
import requests from "./request";
import mockRequests from './mockRequest'

/** 获取首页数据 */
// 获取首页分类三级联动数据
export const reqCategoryList = () => requests({ method: 'get', url: '/product/getBaseCategoryList' });
//获取banner（Home首页轮播图数据）
export const reqGetBannerList = () => mockRequests.get("/banner");
//获取floor数据
export const reqFloorList = () => mockRequests.get("/floor");

/** 获取搜索页数据 */
// 地址：api/list  请求方式：post  参数：{}
export const reqGetSearchInfo = params => {
    return requests({
        method: 'post',
        url: '/list',
        data: params
    })
}

/** 获取详情页数据 */
export const reqGetDetailInfo = skuId => {
    return requests({
        method: 'get',
        url: '/item/' + skuId
    })
}

/** 购物车页面 */
// 添加或修改购物车数据
export const reqAddOrUpdateShopCart = (skuID, skuNum) => {
    return requests({
        method: 'post',
        url: '/cart/addToCart/' + skuID + '/' + skuNum
    })
}

// 获取购物车数据
export const reqGetShopCartInfo = () => {
    return requests({
        method: 'get',
        url: '/cart/cartList'
    })
}

// 删除购物车数据
export const reqDeleteShopCartById = skuId => {
    return requests({
        method: 'delete',
        url: '/cart/deleteCart/' + skuId
    })
}

// 修改商品选中状态
export const reqUpdateCheckById = (skuId, isChecked) => {
    return requests({
        method: 'get',
        url: '/cart/checkCart/' + skuId + '/' + isChecked
    })
}

/** 注册页面 */
// 获取验证码
export const reqGetCode = phone => {
    return requests({
        method: 'get',
        url: '/user/passport/sendCode/' + phone
    })
}

// 注册用户
export const reqUseregister = (data) => {
    return requests({
        method: 'post',
        url: '/user/passport/register',
        data
    })
}

/** 登录页面 */
// 登录
export const reqUserLogin = (data) => {
    return requests({
        method: 'post',
        url: '/user/passport/login',
        data
    })
}

// 获取用户信息：需要携带token
export const reqGetUserInfo = () => {
    return requests({
        method: 'get',
        url: '/user/passport/auth/getUserInfo'
    })
}

// 退出登录
export const reqUserLogout = () => {
    return requests({
        method: 'get',
        url: '/user/passport/logout'
    })
}

/** 订单页面 */
// 1.获取用户地址信息
export const reqAddressInfo = () => {
    return requests({
        method: 'get',
        url: '/user/userAddress/auth/findUserAddressList'
    })
}

// 2.获取订单交易页信息：商品订单
export const reqGetOrderInfo = () => {
    return requests({
        method: 'get',
        url: '/order/auth/trade'
    })
}

// 3.提交订单
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({
        method: 'post',
        url: '/order/auth/submitOrder?tradeNo=' + tradeNo,
        data
    })
}

/** 支付页面 */
// 1.获取支付信息
export const reqGetPayInfo = orderId => {
    return requests({
        method: 'get',
        url: 'payment/weixin/createNative/' + orderId
    })
}

// 2.获取支付订单状态
export const reqGetPayStatus = orderId => {
    return requests({
        method: 'get',
        url: '/payment/weixin/queryPayStatus/' + orderId
    })
}

/** 个人中心页面 */
// 获取我的订单列表
export const reqGetMyOrderList = (page, limit) => {
    return requests({
        method: 'get',
        url: '/order/auth/' + page + '/' + limit
    })
}